#define _CRT_SECURE_NO_WARNINGS 1
#include "Class.h"

void stack::Init()
{
	a = nullptr;
	top = capacity = 0;
}

void stack::push(int x)
{
	if (top == capacity)
	{
		int newcapacity = capacity == 0 ? 4 : capacity * 2;
		a = (int*)realloc(a, sizeof(int) * newcapacity);
		capacity = newcapacity;
	}
	a[top++] = x;
}

int stack::Top()
{
	return a[top - 1];
}



